package com.guigu.erp.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.erp.pojo.User;
import com.guigu.erp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName:UserController
 * Package:com.guigu.erp.controller
 * Description:
 *
 * @Date:2024/5/5 10:11
 * @Author:chenchong
 */
@CrossOrigin
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @ResponseBody
    @RequestMapping("/login")
    public String login(@RequestBody User user) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("LOGIN_ID", user.getLoginId());
        qw.eq("PASSWORD", user.getPassword());
        User one = userService.getOne(qw);
        if (one == null) {
            return "error";
        }
        return user.getLoginId();
    }
}
